package com.itheima;

import com.itheima.service.HelloService;
import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;

public class Client {
    public static void main(String[] args) {
        //服务接口访问地址:http://localhost:8000/ws/hello

        //创建cxf代理工厂
        JaxWsProxyFactoryBean factoryBean = new JaxWsProxyFactoryBean();

        //设置远程访问服务端的地址
        factoryBean.setAddress("http://localhost:8000/ws/hello");

        //设置接口类型
        factoryBean.setServiceClass(HelloService.class);

        //对接口生成代理对象
        HelloService helloService = factoryBean.create(HelloService.class);

        //代理对象对象类型                 [Java代理: 1.静态代理,2.动态代理(jdk接口代理，cglib子类代理)]
        //这里是cglib代理  
        System.out.println(helloService.getClass());

        //远程访问服务端方法
        String sayHello = helloService.sayHello("Jet");
        System.out.println(sayHello);
    }
}
